You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
490 B
13 lines
490 B
import { getArticleById } from "../../service/article";
|
|
|
|
export default defineWrappedResponseHandler(async (event) => {
|
|
const idParam = getRouterParam(event, "id");
|
|
if (!idParam) return R.throwError(400, "缺少文章 ID", null);
|
|
const id = parseInt(idParam);
|
|
if (isNaN(id)) return R.throwError(400, "文章 ID 格式不正确", null);
|
|
|
|
const article = await getArticleById(id);
|
|
if (!article) return R.throwError(404, "文章不存在", null);
|
|
|
|
return R.success(article);
|
|
});
|
|
|